﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Tunnel.DevicesControls.TempFiber
{
    public partial class Fiber : Panel
    {
        public Fiber()
        {
            InitializeComponent();
            for (int i = 0; i < 100; i++)
            {
                FiberPoint fp = new FiberPoint();
                //fp.MaxTemperature = maxTemp;
                int intPos = 96765 + i * 10;
                string stringPos = "K" + intPos.ToString().Substring(0, 2) + "+" + intPos.ToString().Substring(2);
                fp.DevicePos = stringPos;
                fp.Name = "光纤" + fp.DevicePos;
                fp.Location = new Point(i * 10, 0);
                //fp.Temperature = 20;
                fp.Parent = this;
                listFP.Add(fp);
            }
        }

        List<FiberPoint> listFP = new List<FiberPoint>();
        float maxTemp = 100;

        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);
            
        }

        /// <summary>
        /// 按照桩号更新光纤点温度
        /// </summary>
        /// <param name="temperature">该点温度</param>
        /// <param name="pos">要更新的桩号</param>
        public void ChangeTempByPos(float temperature, string pos)
        {
            foreach(FiberPoint fp in listFP)
            {
                if(fp.DevicePos==pos)
                {
                    //fp.Temperature = temperature;
                }
            }
        }
        /// <summary>
        /// 按照编号更新光纤点的温度
        /// 从左至右，第一个点编号为0
        /// </summary>
        /// <param name="temperature">该点温度</param>
        /// <param name="num">该点编号</param>
        public void ChangeTempByNum(float temperature,int num)
        {
            //listFP[num].Temperature = temperature;
        }
    }
}
